Skip to content

journeys export-synthetics: Elastic Synthetics files for the journeys that are monitors - #42

Merged
Mpdreamz merged 1 commit into
mainfrom
feature/export-synthetics
Nov 10, 2026
Merged

Mpdreamz merged 1 commit into
mainfrom
feature/export-synthetics

Conversation

@Mpdreamz

Copy link
Copy Markdown
Contributor

Adds journeys export-synthetics to @nullean/journeys: it writes one Elastic Synthetics journey file for every journey marked @monitor that applies to the flags, build type and environment you give it.

Why

push bundles code, not data files, so a repository that keeps its journeys as .journey files has to generate the Synthetics files, and today everyone would write that generator themselves. The 0.8.0 directives (@monitor, @requires, @alert, @mutates) and feature blocks carry what a generator needs.

What

  • The command. journeys export-synthetics <file, folder or glob>... --out <folder> [--features a,b] [--build-type x] [--env name] [--paging] [--base-url url] [--root folder]. Each generated *.journey.ts has a generated-file header, journey(…), monitor.use({ id, schedule, locations, tags }) from the directives, and journeySteps(…) with the journey text embedded and the run context passed so feature blocks skip at run time exactly as elsewhere.
  • Which journeys export. @monitor is required, @requires must hold for the given context, and @mutates journeys never export. Generated monitors run with readOnly: true. Every journey that does not export is printed with its reason.
  • Alerting. --paging turns @alert pagerduty into alert: { status: { enabled: true } } plus the tag alert:pagerduty for a Kibana rule to route. Without it nothing alert-related is written. Schedule and locations are validated against what Synthetics accepts, so a bad value fails the export, naming the journey.
  • Deterministic output. No timestamps, a stable order. A later export removes only generated files it no longer produces, because push replaces the whole monitor set.

docs/journeys/playwright.md has a new section, and DECISIONS.md records the choices. @elastic/synthetics 1.27.0 is a new dev dependency (the lockfile grows with it) so the tests can run the generated files.

Verify

cd js/journeys && npm ci && npm run build
npm test

Golden files in test/reference/export/ cover: monitor or not, @requires met or not, paging on and off, feature blocks, and escaping of backticks, ${ and backslashes (the template literal is evaluated and compared with the source). export-live.test.ts runs generated files with the real @elastic/synthetics CLI in Chrome against the corpus site: with the flag off the block is skipped and 4 steps pass; with the flag on the block runs and the failing step fails the run. Making paging always on, or ignoring @mutates, each fails a test.

Not tested: a push to Kibana. Known limits: a skipped feature block shows as a passing step in Kibana, and .http files are skipped with a reason until the next PR.

…urneys that are monitors

The command turns each journey with @monitor into a generated *.journey.ts that embeds its text, because
push bundles code and not data files. It judges @requires with the features, build type and environment it
is given, keeps feature blocks for run time, skips @mutates journeys, and turns @Alert pagerduty into alert
configuration only with --paging. The output depends only on the inputs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Mpdreamz
Mpdreamz merged commit 175e4d7 into main Nov 10, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant